package club.looli.haoke.api.graphql;

import club.looli.haoke.api.service.HouseResourcesService;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>
 * Created by looli on 2020/7/11
 * </p>
 *
 * <p>
 * 具体DataFetcher 对应实现
 * haoke.graphql 对应的具体查询
 * </p>
 *
 * @author looli
 * @since 2020/7/11
 */
@Component
public class HouseResourcesDataFetcher implements MyDataFetcher{

    @Autowired
    private HouseResourcesService houseResourcesService;

    @Override
    public String fieldName() {
        return "HouseResources";
    }

    @Override
    public Object dataFetcher(DataFetchingEnvironment environment) {
        Object id = environment.getArgument("id");
        return houseResourcesService.queryById((Long) id);
    }
}
